<?php

/**
 * participant inscription form.
 *
 * @package    forumCDE
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class participantInscriptionForm extends participantForm
{
  public function configure()
  {
  	$this->validatorSchema->setOption('allow_extra_fields', true);
    unset(
      $this['categorie_id'], $this['activeStatus'], $this['administrator'], $this['last_login']
    );
    if($this->getObject()->isNew()){
	    $this->setMandatory('password');
    }
    $this->setMandatory('nomsociete');
    $this->setMandatory('type');
    
    $this->validatorSchema['confirmPassword'] = clone $this->validatorSchema['password'];
    $this->widgetSchema['confirmPassword'] = clone $this->widgetSchema['password'];
    $this->widgetSchema['confirmPassword']->setLabel("Confirm Password");
    $this->widgetSchema['confirmPassword']->setAttribute('tmt:equalto', 'participant_password');
    $this->widgetSchema['confirmPassword']->setAttribute('tmt:message', 'Mots de passe différents');
    $this->widgetSchema->moveField('confirmPassword', 'after', 'password');
    
    $this->validatorSchema['email'] = new sfValidatorAnd(array($this->validatorSchema['email'],new sfValidatorEmail()));
  }
  
  public function afterCommit($self){
  	
  	Util::sendMail(array($self['email']), 'Forum des entrepreneurs', 'no-reply@club-des-entrepreneurs.fr' , 'Vontre inscription au Forum des Entrepreneurs', $this->getBody($self), false);
  	
  }
  
  public function getBody($self){

	  $nom = $self['nom'];	
	  $prenom = $self['prenom'];
	  
	  
	  $body =  <<<BODY
	   Bonjour $prenom $nom,
	
	   Merci de vous avoir inscrit au 5éme forum des entrepreneurs.
	   Vous pouvez modifier votre inscription dans notre site.
	   
	   Cordialement,
	   
	   Le club des entrepreneurs de Picardie.
	  
BODY;
		
	  return $body;
  
  }
  
}
